module PutJSON(renderJValue) where

import SimpleJSON
import Data.List

renderJValue (JString s) = show s
renderJValue (JNumber n) = show n
renderJValue (JBool True) = "true"
renderJValue (JBool False) = "false"
renderJValue JNull = "null"

renderJValue (JArray a) = showTransformedList "[" "]" renderJValue a

renderJValue (JObject o) = showTransformedList "{" "}" renderPair o
    where renderPair (k,v) = show k ++ ": " ++ renderJValue v

showTransformedList start end transformer values =
    start ++ (intercalate ", " (map transformer values)) ++ end
